package team.szm.scd.service.impl;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
import team.szm.scd.database.entity.Register;
import team.szm.scd.database.vo.RegisterRemainVO;
import team.szm.scd.database.vo.RegisterVO;
import team.szm.scd.utils.TimeUtils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Profile("test")
@Service
@Slf4j
public class TestRegisterServiceImpl extends AbstractRegisterService {
    @SneakyThrows
    @Override
    public synchronized boolean addRegister(Register register, LocalDateTime now) {
        now = LocalDateTime.of(TimeUtils.testNowDate(), TimeUtils.testNowTime());
        return super.addRegister(register, now);
    }

    public TestRegisterServiceImpl() {
        log.trace("测试环境的RegisterService");
    }

    @Override
    @SneakyThrows
    public List<RegisterVO> registersDoctorHave(String doctorId, LocalDate today) {
        today = TimeUtils.testNowDate();
        return super.registersDoctorHave(doctorId, today);
    }

    @SneakyThrows
    @Override
    public List<RegisterRemainVO> registerRemainInfo(int hospitalId, int departmentId, LocalDate today) {
        today = TimeUtils.testNowDate();
        return super.registerRemainInfo(hospitalId, departmentId, today);
    }
}
